<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="renderer" content="webkit" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>千峰教育大前端Vue教学</title>
  <script src="https://cdn.staticfile.org/petite-vue/0.4.1/petite-vue.umd.min.js"></script>
</head>

<body style="margin:100px;font-size:22px;">
  <div v-scope>
    <div>num = {{ num }}</div>
    <div>num2 = {{ num2 }}</div>
    <div>num3 = {{ num3 }}</div>
    <div><button @click="add">num++</button></div>
    <div><button @click="sub(3)">num--</button></div>
  </div>

  <script>
    PetiteVue.createApp({
      num: 0,
      // getters
      get num2() {
        return this.num * 2
      },
      get num3() {
        return this.num * 3
      },
      // methods
      add() {
        this.num++
      },
      sub(n) {
        this.num -= n;
      },
    }).mount()
  </script>
</body>

</html>